package com.webblog.service.blog;

import com.webblog.dao.blog.BlogMapper;
import com.webblog.pojo.Blog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogServiceImpl implements BlogService{

    @Autowired
    private BlogMapper blogMapper;

    public Integer addnewBlog(Blog blog) {
        blogMapper.insertNewBlog(blog);
        return blog.getBlogId();
    }

    public List getBlogList(int isDraft) {
        return blogMapper.getBlogList(isDraft);
    }

    public Blog getBlogDetail(int blogId) {
        return blogMapper.getBlogDetailById(blogId);
    }

    public Integer updateBlog(Blog blog) {
        return blogMapper.updateBlog(blog);
    }

    public Integer setRecovery(int blogId) {
        return blogMapper.toRecovery(blogId);
    }

    public Integer recoveryBlog(int blogId) {
        return blogMapper.recovery(blogId);
    }

    public List getCoveryList(int isCovery) {
        return blogMapper.getCoveryList(isCovery);
    }

    public Integer deleteBlog(int blogId) {
        return blogMapper.deleteBlog(blogId);
    }

    public Integer publishBlog(int blogId) {
        return blogMapper.publishBlog(blogId);
    }

    public List searchBlog(String title) {
        return blogMapper.searchBlog(title);
    }

    public List getRecentBlog() {
        return blogMapper.getRecentBlog();
    }

    public List getBlogByClassifyId(int classifyId) {
        return blogMapper.getBlogByClassifyId(classifyId);
    }

    public Integer updateReadCount(int blogId) {
        return blogMapper.updateReadCount(blogId);
    }


}
